<form method="POST" action="index.php?<{$env.server.QUERY_STRING}>" class="tableform" id="gift_form">
    <{input type="hidden" name="id" value=$rs.gift_id }>
    <div class="division1">

        <table width="100%" border="0" cellpadding="0" cellspacing="0" >
            <tr>
                <th><{t}>赠品名称：<{/t}></th>
                <td>
                    <{$rs.gift_name}>
                </td>
            </tr>
            <tr>
                <th><{t}>商家编码：<{/t}></th>
                <td>
                    <{$rs.gift_bn}>
                </td>
            </tr>
            <tr>
                <th><{t}> 赠品数量设置：<{/t}></th>
                <td>
                   <input type="radio" name="giftset" class='giftset' value='0' <{if $rs.giftset=='0'  || $rs.giftset==''}>checked<{/if}>> 指定数量
                    <input type="radio" name="giftset" class='giftset' value='2' <{if $rs.giftset=='2'}>checked<{/if}>> 实际库存数量
                    <input type="radio" name="giftset" class='giftset' value='1' <{if $rs.giftset=='1'}>checked<{/if}>> 不限数量

                </td>
            </tr>
            <tr class='gifthtml'>
                <th><{t}>赠送数量：<{/t}></th>
                <td>
                    <{input type="text" id="gift_num" name="gift_num" value=$rs.gift_num size="4" }>
                </td>
            </tr>
            <tr>
                <th><{t}>已 送 出：<{/t}></th>
                <td>
                    <{$rs.send_num}>
                </td>
            </tr>
            <tr>
                <th><em class="c-red">*</em><{t}>状　　态：<{/t}></th>
                <td>
                    <label>
                        <input type="radio" value="0" name="is_del" /> 启用
                    </label>
                    　　　　　　
                    <label>
                        <input type="radio" value="1" name="is_del" /> 禁用
                    </label>
                </td>
            </tr>
        </table>

    </div>
    <input type="hidden" name="product_id" value="<{$rs.product_id}>">
</form>

<{area inject='.mainFoot'}>
<div class="table-action">
    <{button type="button" label="保存" id="save_btn"}>
</div>
<{/area}>

<script>
    var is_del = <{$rs.is_del}>;

    (function(){

        $$('input[name="is_del"][value='+is_del+']').set('checked','checked');

        $('save_btn').addEvent('click', function(){

            if(!$('gift_num').value){
                alert("请输入数字");
                $('gift_num').focus();
                return false;
            }

            $('gift_form').fireEvent('submit',{stop:$empty});
        });

        var _form = $('gift_form');
        var btn =$('save_btn');

        _form.store('target',{
            onSuccess:function(response){
                var hash_res_obj = JSON.decode(response);

                if (hash_res_obj.success != undefined && hash_res_obj.success != "")
                {
                    try{
                        var _dialogIns = btn.getParent('.dialog').retrieve('instance');
                    }catch(e){}

                    if(_dialogIns)
                    {
                        _dialogIns.close();
                    }
                }
            }
        });

    })();
$$('.giftset').addEvent('click',function(e){

    showgift(this.value)
});

function showgift(value){
    if (value == '0' || value== '')
    {
        $$('.gifthtml').setStyle('display','');
    }else{
       
        $$('.gifthtml').setStyle('display','none');
    }
}
var giftsetvalue = $$('input[name=giftset]:checked').get('value');
showgift(giftsetvalue);
</script>
